import React, { Component } from 'react'
import { Button, Row, Col, Divide } from 'antd';
import { Redirect } from "react-router-dom"
import Test from "../../components/test/Test"
import"./home.scoped.less"
 import Alert from "../../components/Alert"

export default class Home extends Component {
  componentDidUpdate() {
  }
  toPath = (path) => {
    let { history } = this.props
    history.push(path)
  }
  loginOut=()=>{
    let { history } = this.props
    localStorage.removeItem("token")
    history.replace("/login")
  }
  alert=()=>{
    Alert({
      title:"alert"
    }).then(res=>{
      console.log('Alertthen')
    }).catch(res=>{
      console.log('Alertcatch')
    })
  }
  // close=()=>{
  //   Alert.close()
  // }
  render() {
    // let token = localStorage.getItem("token")

    // if(!token){
    //   return <Redirect to="/login"></Redirect>
    // }
  //  let { location } = this.props
  //  if(location.pathname == "/login"){
  //    return ""
  //  }
    return (
      <div>
        <div>
          <Row justify="center">
            <Col span={4}>
              <Button type="primary" onClick={() => { this.toPath("/index") }}>to Index</Button>
            </Col>
            <Col span={4}>
              <Button type="primary" onClick={() => { this.toPath("/index/goods") }}>to /goods/gl</Button>
            </Col>
            <Col span={4}>
              <Button type="primary" onClick={() => { this.toPath("/index/goods/classity") }}>to /goods/classity</Button>
            </Col>
            <Col span={4}>
              <Button type="primary" onClick={() => { this.toPath("/index/goods/jiaju/yizi") }}>to jiaju</Button>
            </Col>
            <Col span={4}>
              <Button type="primary" onClick={this.loginOut }>登出</Button>
            </Col>
          </Row>
        </div>
        <p className="title">Home</p>
        <Test></Test>
        <div>
        <Button type="primary" onClick={this.alert }>Alert open</Button>
        <Button type="primary" onClick={this.close }>Alert colse</Button>
        
        </div>
        {this.props.children}
      </div>
    )
  }
}
